%%% Written by  Daniel Lewis, 2020, for "Robust Inference in Models 
%%% Identified via Heteroskedasticity", Review of Economics and Statistics.
%
% This file produces Figure 1, extending Figure 1 from Rigobon & Sack
% (2004). The parameter values are arbitrary, chosen only to illustrate the
% points in the text. 

clear; clc

% Construct H
a=.4;
b=-.4;
H=[1 a;b 1];

% Initialize figure
figure
subplot1(1,4,'FontS',12,'Gap',[.01,.01]);
rng(715) % seed rng

%% Panel 1 
eta1=(H*randn(200,2)')';
subplot1(1)
scatter(eta1(:,1),eta1(:,2),'Marker','.');
xlim([-20 20])
ylim([-20 20])
r1=refline(a,0);
r1.Color='k';
r1.LineStyle='-.';
r1.LineWidth=1.5;
r2=refline(b,0);
r2.Color='k';
r2.LineStyle='--';
r2.LineWidth=1.5;
ylabel('Asset Price')
xlabel('Interest Rate')
xticks([])
yticks([])
title('Control Days')

%% Panel 2
eta2=(H*diag([11;1.5])*randn(200,2)')';
subplot1(2)
scatter(eta2(:,1),eta2(:,2),'Marker','.');
xlim([-20 20])
ylim([-20 20])
r=refline(a,0);
r.Color='k';
r.LineStyle='-.';
r.LineWidth=1.5;
r=refline(b,0);
r.Color='k';
r.LineStyle='--';
r.LineWidth=1.5;
xlabel('Interest Rate')
xticks([])
yticks([])
title('Policy: Strong ID')

%% Panel 3
eta2=(H*diag([2;1])*randn(200,2)')';
subplot1(3)
scatter(eta2(:,1),eta2(:,2),'Marker','.');
xlim([-20 20])
ylim([-20 20])
r=refline(a,0);
r.Color='k';
r.LineStyle='-.';
r.LineWidth=1.5;
r=refline(b,0);
r.Color='k';
r.LineStyle='--';
r.LineWidth=1.5;
xlabel('Interest Rate')
xticks([])
yticks([])
title('Policy: Small Change')

%% Panel 4
eta2=(H*diag([6;5])*randn(200,2)')';
subplot1(4)
scatter(eta2(:,1),eta2(:,2),'Marker','.');
xlim([-20 20])
ylim([-20 20])
r=refline(a,0);
r.Color='k';
r.LineStyle='-.';
r.LineWidth=1.5;
r=refline(b,0);
r.Color='k';
r.LineStyle='--';
r.LineWidth=1.5;
xlabel('Interest Rate')
xticks([])
yticks([])
title('Policy: Near-proportional Changes')

%% Add legend
subplot1(1)
legend([r1,r2],{'Monetary Policy Response','Asset Price Response'},'Location','southeast')
legend boxoff
